// //获取数据
// $(function(){
//     $.ajax({
//         url:"../../api/data-teacher.json",
//         success:function(data){
//             let myUser=JSON.stringify(data.data);
//             localStorage.setItem("tuser",myUser);
//         }
//     })
// })

//注册验证
function resiger(){
//获取文本框的值
//电话号码
let Tel=$("#resiger-btn").parent().parent().children().children("#tel").val();
//邮箱
let tMail=$("#resiger-btn").parent().parent().children().children("#tmail").val();
//密码
let tPsw1=$("#resiger-btn").parent().parent().children().children("#tpsw1").val();
//二次密码
let tPsw2=$("#resiger-btn").parent().parent().children().children("#tpsw2").val();
//创建正则规则
let regPhone=/^(\d){6,11}$/
let regEmail=/(\w){1,11}@(\w)+.(\w){2,}$/
let regPsw=/^(\w){5,10}$/
//json数据
let tuser=JSON.parse(localStorage.getItem("key"));
//能拿到数据
// console.log(Tel+tMail+tPsw1+tPsw2);
//将tuser循环
for(let i=0;i<tuser.length;i++){
    if(regPhone.test(Tel)==true && regEmail.test(tMail)==true && regPsw.test(tPsw1)==true){
        if(Tel!=tuser[i].tel && tMail!=tuser[i].mail){
            if(tPsw1==tPsw2){
                let tArray={
                    "id":"t012",
                    "tel":Tel,
                    "mail":tMail,
                    "password":tPsw2,
                    "userName":"",
                    "birthday":"",
                    "sex":"",
                    "QQ":"",
                    "emergency":"",
                    "department":"",
                    "position":"",
                    "number":"",
                    "address":"",
                    "marriage":"",
                    "educational":"",
                    "age":""
                }
                tuser.push(tArray);
                let tUser=JSON.stringify(tuser);
                localStorage.setItem("key",tUser);
                $(location).attr("href","../login/login.html");
                alert("注册成功！");
                break;
            }else{
                alert("两次密码输入不一致，请重新输入！");
                break;
            }
        }else{
            alert("该号码或邮箱已被注册！");
            break;
        }
    }else if (regPhone.test(Tel)==false) {
        alert("联系方式输入格式不正确，请重新输入！");
        $("#resiger-btn").parent().parent().children().children("#tel").val("");
        break;
    }else if(regEmail.test(tMail)==false){
        alert("邮箱输入格式不正确，请重新输入！");
        $("#resiger-btn").parent().parent().children().children("#tmail").val("");
        break;
    }else if(regPsw.test(tPsw1)==false){
        alert("密码输入格式不正确，请重新输入！");
        $("#resiger-btn").parent().parent().children().children("#tpsw1").val("")
        break;
    }
}
console.log(tuser)
}